class Solution
{
public:
    vector<vector<int>> largeGroupPositions(string s)
    {
        int begin = 0;
        int end = 0;
        int n = s.size();
        vector<vector<int>> result;
        while (end < n)
        {
            if (s[begin] == s[end])
            {
                ++end;
            }
            else
            {
                if (end - begin >= 3)
                {
                    result.push_back({begin, end - 1});
                }
                begin = end;
            }
        }
        if (end - begin >= 3)
        {
            result.push_back({begin, end - 1});
        }
        return result;
    }
};